package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.Class;
import cn.wolfcode.crm.mapper.ClassMapper;
import cn.wolfcode.crm.query.ClassQueryObject;
import cn.wolfcode.crm.service.IClassService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClassServiceImpl implements IClassService {
    @Autowired
    private ClassMapper classMapper;

    @Override
    public void deleteByPrimaryKey(Long id) {
        classMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void insert(Class entity) {
        classMapper.insert(entity);
    }

    @Override
    public Class selectByPrimaryKey(Long id) {

        return classMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Class> selectAll() {
        return classMapper.selectAll();
    }

    @Override
    public void updateByPrimaryKey(Class entity) {
        classMapper.updateByPrimaryKey(entity);
    }

    @Override
    public void changState(Long id) {
        classMapper.changState(id);
    }


    public PageResult query(ClassQueryObject qo) {
        Integer total = classMapper.query4Count(qo);
        if (total == 0) {
            return PageResult.PAGERESULT_EMPTY;
        }
        return new PageResult(total, classMapper.query4List(qo));
    }

}
